package com.crm.manager.utils;

import java.time.Duration;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;

public class TimeIntervalString {
    public static String[] getTimeIntervalsAsStringArray(LocalDate beginTime, LocalDate endTime) {
        List<String> intervalStrings = new ArrayList<>();
        LocalDate currentTime = beginTime;

        while (!currentTime.isAfter(endTime)) {
            LocalDate nextTime = currentTime.plusDays(1);
        /*    if (nextTime.isAfter(endTime)) {
                nextTime = endTime;
            }*/
            intervalStrings.add(currentTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
            currentTime = nextTime;
        }
        return intervalStrings.toArray(new String[0]);
    }
}
